﻿@using SmartStore.Core.Logging;

@if (this.HasMessages)
{
	<script>
        $(function () {
        	var items = $("#notification-list").find("> .msg");
            items.each(function (i, el) {
                el = $(el);
                var type = el.data("type");
                var sticky = type != "success" && type != "info";
                var delay = type == "success" ? 3500 : 5000;
                var notify = function () {
                	EventBroker.publish("message", {
                		text: el.html(),
                		type: type,
                		delay: delay,
                		hide: !sticky,
                		icon: true,
						shadow: false
                	});
                };
                _.delay(notify, 100 * i);
            });
        })
	</script>

	<div id="notification-list" class="d-none" style="position:absolute; left:-9999px">
		@foreach (var message in this.GetMessages(NotifyType.Error))
        {
			<div class="msg" data-type="error">@Html.Raw(message)</div>
        }
		@foreach (var message in this.GetMessages(NotifyType.Success))
        {
			<div class="msg" data-type="success">@Html.Raw(message)</div>
        }
		@foreach (var message in this.GetMessages(NotifyType.Info))
        {
			<div class="msg" data-type="info">@Html.Raw(message)</div>
        }
		@foreach (var message in this.GetMessages(NotifyType.Warning))
        {
			<div class="msg" data-type="warning">@Html.Raw(message)</div>
        }
	</div>

	Html.RenderWidget("notifications");
}

